package main

import (
	"flag"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/logs"

	// "github.com/astaxie/beego/plugins/cors"
	_ "github.com/astaxie/beego/session/redis"

	_ "lottery/routers"
)

var LogLevel map[string]int = map[string]int{
	"emergency": logs.LevelEmergency,
	"alert":     logs.LevelAlert,
	"critical":  logs.LevelCritical,
	"error":     logs.LevelError,
	"warning":   logs.LevelWarning,
	"notice":    logs.LevelNotice,
	"info":      logs.LevelInformational,
	"debug":     logs.LevelDebug,
}

var level int

func init() {
	flag.IntVar(&level, "level", 7, "日志级别")
}

func main() {
	flag.Parse()
	logs.SetLevel(level)
	logs.SetLogFuncCall(true)
	logs.SetLogFuncCallDepth(3)

	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
	}

	// set log level
	logs.SetLevel(LogLevel[beego.AppConfig.String("logLevel")])

	beego.Run()
}
